#!/bin/sh

## Version variables (change them! ;-) )
ORIG_VERSION=omnibus-backend_0.2.7.1.orig.tar.gz
PKG_VERSION=0.2.7.1-0

export DEBFULLNAME="Mario Hock"
export DEBEMAIL="launchpad@mario.omnifile.org"


## make sure we're packaging the correct version
clear
echo "Hello, nice you're packaging a new Omnibus-bin version. :-)"
echo
echo "Full Name: $DEBFULLNAME"
echo "Orig version: $ORIG_VERSION"
echo "PKG version: $PKG_VERSION"
echo
echo "Are they correct? [y/N]"

read ok
case $ok in
  j*|J*|y*|Y*) echo "let's go" ;;
  *) echo "change: $PWD/$0"; echo; echo "cancel."; exit 1 ;;
esac

# don't mess with an existing directory
if [ -e /tmp/pack ]; then
    echo "ERROR: '/tmp/pack' already exists."
    echo
    echo "cancel."
    
    exit 1
fi



## OKAY! GO. ##

## Code kopieren und orig.tar.gz packen
mkdir /tmp/pack
cd /tmp/pack/
svn export /home/mario/programmieren/Projekte/Omnibus/stable/omnibus-filetransfer/omnibus-backend
#svn export /home/mario/programmieren/Projekte/omnibus-filetransfer/omnibus-backend
tar -cvzf $ORIG_VERSION omnibus-backend/

## changelog schreiben
cd /home/mario/programmieren/Projekte/Omnibus/PKG-omnibus/ubuntu/backend
dch -v $PKG_VERSION
svn export debian /tmp/pack/omnibus-backend/debian


## ask if allright before pack&upload
echo
echo "Good. Pack & Upload? [y/N]"
read ok
case $ok in
  j*|J*|y*|Y*) echo "let's go." ;;
  *) echo "cancel."; exit 0 ;;
esac


## debuild und dput -> hochladen
cd /tmp/pack/omnibus-backend
debuild -S && dput ppa:omnibus-filetransfer/ppa ../*_source.changes


## repack for alternative ubuntu version
## ask if allright before pack&upload
echo
echo "Upload finished. Create quantal package too? [y/N]"
read ok
case $ok in
  j*|J*|y*|Y*) echo "let's go." ;;
  *) echo "cancel."; exit 0 ;;
esac

vim debian/changelog

## ask if allright before pack&upload
echo
echo "Good. Pack & Upload? [y/N]"
read ok
case $ok in
  j*|J*|y*|Y*) echo "let's go." ;;
  *) echo "cancel."; exit 0 ;;
esac


## debuild und dput -> hochladen
cd /tmp/pack/omnibus-backend
debuild -S && dput ppa:omnibus-filetransfer/ppa ../*~quantal_source.changes


echo
echo "bye."
echo
echo "p.s. don't forget to check in the changed debian directory"

